#include <iostream>
#include <vector>
#include <tuple>

using namespace std;

class WeightedGraph_ban {
private:
    int numVertices;
    vector<int> adjacencyMatrix;

public:
    WeightedGraph_ban(int numVertices) : numVertices(numVertices) {
        int matrixSize = numVertices * (numVertices -1) / 2;  // 计算下半部分对称元素数量
        adjacencyMatrix.resize(matrixSize, 0);//创建下半数组的空间
    }

    void addEdge(int src, int dest, int weight) {
        // 确保 src < dest
        if (src > dest)
            swap(src, dest);

        int index = dest * (dest - 1) / 2 + src;  // 计算元素索引
        adjacencyMatrix[index] = weight;
    }

    int getWeight(int src, int dest) {
        // 确保 src < dest
        if (src > dest)
            swap(src, dest);

        int index = dest * (dest - 1) / 2 + src;  // 计算元素索引
        return adjacencyMatrix[index];
    }

    void printGraph() {
        int index = 0;
        for (int i = 1; i < numVertices; ++i) {
//            if(!i){cout<<"0"<<endl;
//                continue;}
            for (int j = 0; j < i; ++j) {
                cout << adjacencyMatrix[index] << " ";
                ++index;
            }
//            cout <<"0"<< endl;
              cout<<endl;
        }
    }
};

//int main() {
//    int numVertices = 5;  // 顶点数
//
//    WeightedGraph_ban graph(numVertices);
//    graph.addEdge(0, 1, 2);
//    graph.addEdge(1, 2, 3);
//    graph.addEdge(2, 3, 4);
//    graph.addEdge(3, 4, 5);
//    graph.addEdge(4, 0, 6);
//
//    cout << "Graph adjacency matrix:" << endl;
//    graph.printGraph();
//
//    return 0;
//}